﻿using SFML.System;

namespace WolfCarol.SFU
{
    public static class Vector2Extensions
    {
        public static Vector2f Zero = new Vector2f(0f, 0f);

        public static Vector2f One = new Vector2f(1f, 1f);

        public static Vector2f Left = new Vector2f(-1f, 0f);

        public static Vector2f Right = new Vector2f(1f, 0f);

        public static Vector2f Up = new Vector2f(0f, -1f);

        public static Vector2f Down = new Vector2f(0f, 1f);

        public static float Magnitude(this Vector2f v)
        {
            return MathF.Sqrt(v.X * v.X + v.Y * v.Y);
        }

        public static Vector2f Normalized(this Vector2f v)
        {
            return v == Zero ? v : v / v.Magnitude();
        }

        public static float Distance(Vector2f a, Vector2f b)
        {
            return (a - b).Magnitude();
        }

        public static Vector2f Lerp(Vector2f a, Vector2f b, float t)
        {
            return a + (b - a) * t;
        }
    }
}
